package com.yaoli.hihocoder;

import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

/**
 * Created by will on 2017/4/8.
 */
public class _QueenAttack {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);

        int rownums = input.nextInt();

        int data[][] = new int[rownums][2];

        for(int i = 0 ; i < data.length ; i++){
            data[i][0] = input.nextInt();
            data[i][1] = input.nextInt();
        }

        Map<Integer,Integer> row = new HashMap<>();
        Map<Integer,Integer> col = new HashMap<>();

        Map<Integer,Integer> positive = new HashMap<>();
        Map<Integer,Integer> negitive = new HashMap<>();


        int z = 0;

        for (int i = 0; i < data.length; i++) {

            if(row.get(data[i][0]) == null){
                row.put(data[i][0],1);
            }else{
                row.put(data[i][0],row.get(data[i][0])+1);
            }

            if(col.get(data[i][1]) == null){
                col.put(data[i][1],1);
            }else{
                col.put(data[i][1],col.get(data[i][1])+1);
            }

            // y = x + z ==> z = y - x;
            // y = -x + z ==> z = y + x;

            z = data[i][1] - data[i][0];

            if(positive.get(z) == null){
                positive.put(z,1);
            }else{
                positive.put(z,positive.get(z)+1);
            }

            z = data[i][1] + data[i][0];
            if(negitive.get(z) == null){
                negitive.put(z,1);
            }else {
                negitive.put(z, negitive.get(z) + 1);
            }

        }

        int total = 0;
        for(Integer i : row.keySet()){
            if(row.get(i) > 1){
                total = total + row.get(i)*(row.get(i) - 1) / 2;
            }
        }

        for(Integer i : col.keySet()){
            if(col.get(i) > 1){
                total = total + col.get(i)*(row.get(i) - 1) / 2;
            }
        }

        for(Integer i : positive.keySet()){
            if(positive.get(i) > 1){
                total = total + positive.get(i)*(positive.get(i) - 1) / 2;
            }
        }

        for(Integer i : negitive.keySet()){
            if(negitive.get(i) > 1){
                total = total + negitive.get(i)*(negitive.get(i) - 1) / 2;
            }
        }

        System.out.println(total);
    }

}
